inspector: Avoid crash when canceling at startup
authorDaiki Ueno <dueno@src.gnome.org>
Tue, 22 Dec 2015 02:21:56 +0000 (11:21 +0900)
committerDaiki Ueno <ueno@gnu.org>
Tue, 22 Dec 2015 03:52:27 +0000 (12:52 +0900)
When clicking "Cancel" on the "Do you want to use GTK+ Inspector?"
dialog, unregister the update_debugging idle handler.  Also, steal
reference to 'inspector_window' while gtk_destroy_widget(), to make
further gtk_window_update_debugging() calls as a no-op.

https://bugzilla.gnome.org/show_bug.cgi?id=759764

gtk/gtkwindow.c

index a513e6c1d0461dfabef048e8669db1553b7bbae1..d371ba3b26af106d44bfee84189f0decaed254d7 100644 (file)
@@ -12143,6 +12143,8 @@ _gtk_window_raise_popover (GtkWindow *window,
 
 static GtkWidget *inspector_window = NULL;
 
+static guint gtk_window_update_debugging_id;
+
 static void set_warn_again (gboolean warn);
 
 static void
@@ -12159,8 +12161,19 @@ warn_response (GtkDialog *dialog,
   g_object_set_data (G_OBJECT (inspector_window), "warning_dialog", NULL);
   if (response == GTK_RESPONSE_NO)
     {
-      gtk_widget_destroy (inspector_window);
+      GtkWidget *window;
+
+      if (gtk_window_update_debugging_id)
+        {
+          g_source_remove (gtk_window_update_debugging_id);
+          gtk_window_update_debugging_id = 0;
+        }
+
+      /* Steal reference into temp variable, so not to mess up with
+         inspector_window during gtk_widget_destroy().  */
+      window = inspector_window;
       inspector_window = NULL;
+      gtk_widget_destroy (window);
     }
   else
     {
@@ -12168,8 +12181,6 @@ warn_response (GtkDialog *dialog,
     }
 }
 
-static guint gtk_window_update_debugging_id;
-
 static gboolean
 update_debugging (gpointer data)
 {